/*
Copyright (c) 2006 - 2008  Universitaet Osnabrueck, virtUOS
Authors: Markus Ketterl, Johannes Emden, Nils Schuhmacher, Andreas Rickling

This file is part of virtPresenter.

virtPresenter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

virtPresenter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with virtPresenter.  If not, see <http://www.gnu.org/licenses/>.
*/

package virtPresenter.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import flash.net.LocalConnection;
	
	import virtPresenter.event.*;
	import virtPresenter.model.virtPresenterLocator;
	
	/**
	 * Command lets the presentation go to the selected animationStep.
	 * */
  	public class GoToAnimationStep implements ICommand {	
		
		/**
		 * Handler for GoToAnimationStepEvent. Lets the presentation go to the animation step given
		 * through the event.
		 * 
		 * @see virtPresenter.event.GoToAnimationStepEvent;
		 * 
		 * */	
		public function execute( event : CairngormEvent ): void {
			
				var model : virtPresenterLocator = virtPresenterLocator.getInstance();
				var animStepSelected : GoToAnimationStepEvent =GoToAnimationStepEvent( event );
				model.prevAS=animStepSelected.prevNum;
				model.nextAS=animStepSelected.nextNum;
				model.currentAnimStep=animStepSelected.animationStepNumber;
			
										
				try {
					trace("GoToAnimationStep. Animation step:" +animStepSelected.animationStepNumber);
					
					//model.flex2swfConnector.sendingLC.send("swf8connector","goToAnimStep_lc",Number(animStepSelected.animationStepNumber));
					model.mainWindowProxy.requestAnim(Number(animStepSelected.animationStepNumber));
					model.previewLeftProxy.requestAnim(Number(animStepSelected.prevNum));
					model.previewMiddleProxy.requestAnim(Number(animStepSelected.animationStepNumber));
					model.previewRightProxy.requestAnim(Number(animStepSelected.nextNum));				
				}
				catch(error:ArgumentError) {
					trace ("GoToAnimationStep. Error in sendingLC!")
				};
				
		}
	
		
	}
	
	
}